import unittest

import app
from aip.login_demo import loginDemoAPI
from utils import common_assert


class Test01LoginDemo(unittest.TestCase):
    # 前置处理
    def setUp(self) -> None:
        self.login_d_api = loginDemoAPI()
        print(123123132)



    # 登录
    def test01_login_d(self):
        response = loginDemoAPI().login_d({"mobile":"13800000002", "password":"123456"})
        print(response.json())
        app.TOKEN ="Bearer " +response.json().get("data")
        app.headers_data["Authorization"] = app.TOKEN
        print(app.headers_data["Authorization"])
        common_assert(self, response)


    # 账号不写
    def test02__is_not_mobile(self):
        response = self.login_d_api.login_d({"mobile": "", "password": "123456"})
        print(response.json())
        # 断言
        common_assert(self, response, 200, False, 20001, "用户名或密码错误")

    # 密码不写
    def test03_is_not_password(self):
        response = self.login_d_api.login_d({"mobile": "13800000002", "password": ""})
        print(response.json())
        # 断言
        common_assert(self, response, 200, False, 20001, "用户名或密码错误")


